
#ifndef MY_GCREATEREGISTRYVALUE
#define MY_GCREATEREGISTRYVALUE

// Create a registry key and set its value.
DWORD gCreateRegistryKeyValue(
        HKEY hKeyParent,
        PCWSTR KeyName,
        REGSAM rsAccessMask,
        REGSAM rsSamViewFlag,
        CONST WCHAR* pValue,
        DWORD dwValueSize
        )
{
 	DWORD dwRet;
    DWORD dwDisposition;
    HKEY  hKey;
    
    dwRet = 
        RegCreateKeyExW(
            hKeyParent,
            KeyName,
            0,
            NULL,
            REG_OPTION_NON_VOLATILE,
            rsAccessMask | rsSamViewFlag,
            NULL,
            &hKey,
            &dwDisposition);
            
    if (dwRet == ERROR_SUCCESS) {
	    // Attempt to set the value of the key.
	    // If the call fails, close the key and return.
	    dwRet =  RegSetValueW(
	                hKey,
	                NULL,
	                REG_SZ,
	                pValue,
	                dwValueSize);
    
	    RegCloseKey(hKey);
    }
	
    return dwRet;
}


#endif

